package ar.edu.utn.frsf.tpae.a2012.g02.dao.implementacion;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import ar.edu.utn.frsf.tpae.a2012.g02.dao.MovimientoPagoDAO;
import ar.edu.utn.frsf.tpae.a2012.g02.models.MovimientoPago;

public class MovimientoPagoHibernateDAO extends
		GenericHibernateDAO<MovimientoPago> implements MovimientoPagoDAO {

	private SessionFactory sessionFactory = new AnnotationConfiguration()
			.configure().buildSessionFactory();

	@Override
	public MovimientoPago getByCodigoPago(String codigoPago) {
		Session session = sessionFactory.openSession();
		Query query = session.createQuery("from "
				+ MovimientoPago.class.getName()
				+ " where codigoPago = :codigoPago");
		query.setString("codigoPago", codigoPago);
		return (MovimientoPago) query.uniqueResult();
	}
}
